// Declare a unique namespace.
var LuisVielva_svg_visualization;

if (typeof(LuisVielva_svg_visualization) == 'undefined')
{
	LuisVielva_svg_visualization = {};
}

// Declare a unique namespace.
var LuisVielva_svg_visualization = {};

// Class constructor. Parameter container is a DOM elementon the client that
// that will contain the visualization.
LuisVielva_svg_visualization.Pelota = function(container) 
{
	this.containerElement = container;
	this.svgns = "http://www.w3.org/2000/svg";
}

// Main drawing logic.
// Parameters:
//   data is data to display, type google.visualization.DataTable.
//   options is a name/value map of options. Our example takes one option.
LuisVielva_svg_visualization.Pelota.prototype.draw = function(data, options) 
{
	var radius = options.radius;
	var color = options.color;
	var caption = options.caption;
	
	var svgroot = document.createElementNS(this.svgns, 'svg');
	svgroot.setAttributeNS(null, 'width', 2*radius);
	svgroot.setAttributeNS(null, 'height', 2*radius);
	
	var circulo = document.createElementNS(this.svgns, 'circle');
	circulo.setAttributeNS(null, 'cx', radius);
	circulo.setAttributeNS(null, 'cy', radius);
	circulo.setAttributeNS(null, 'r', radius);
	circulo.setAttributeNS(null, 'fill', color);
	svgroot.appendChild(circulo);
	
	if (typeof(caption) != 'undefined' && caption != null)
	{
		var texto = document.createElementNS(this.svgns, 'text');
		texto.setAttributeNS(null, 'x', radius);
		texto.setAttributeNS(null, 'y', radius);
		texto.setAttributeNS(null, 'text-anchor', 'middle');
		texto.appendChild(document.createTextNode(caption));
		svgroot.appendChild(texto);
	}
	
	this.containerElement.appendChild(svgroot);

  	
  	// data.getNumberOfColumns();
  	// this.escapeHtml(data.getColumnLabel(col)
  	// data.getNumberOfRows();
  	// data.getColumnType(col) == 'number'
  	// this.escapeHtml(data.getFormattedValue(row, col)
}

// Utility function to escape HTML special characters
LuisVielva_svg_visualization.Pelota.prototype.escapeHtml = function(text) 
{
	return (text == null) ? '' : 
	       text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
}
